/*
 * Copyright 2013 Glassy Cinema.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hu.glassy.web.panel.movie.list;

import hu.glassy.core.model.Movie;
import hu.glassy.web.page.movie.edit.MovieEditPage;
import hu.glassy.web.panel.common.CustomPanel;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;

/**
 * Displayes an item in the movie list.
 *
 * @author Alexander Molnár <molnar.alexander@sonrisa.hu>
 */
public final class MovieListItem extends CustomPanel<Movie>
{

  /**
   * Constructor
   *
   * @param id    Component ID
   * @param movie The movie to display
   */
  public MovieListItem(String id, IModel<Movie> movie)
  {
    super(id, movie);
    setDefaultModel(new CompoundPropertyModel<Movie>(movie));

    PageParameters params = new PageParameters();
    params.add("id", movie.getObject().getId());
    Link editLink = new BookmarkablePageLink("editLink", MovieEditPage.class, params);
    editLink.add(new Label("title"));
    add(editLink);

    add(new Label("shortDescription"));
  }
}
